<%@page import="java.util.ArrayList"%>
<%@page import="com.situ.web.entity.Banji"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="header.jsp"%>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form id="formId" class="layui-form layui-form-pane"  method="post" action="">
	  <div class="layui-form-item">
	    <label class="layui-form-label">课程名</label>
	    <div class="layui-input-inline">
	      <input type="text" name="name" autocomplete="off" placeholder="请输入课程名" class="layui-input">
	    </div>
	  </div>
	   <div class="layui-form-item">
	    <label class="layui-form-label">学分</label>
	    <div class="layui-input-inline">
	      <input type="text" name="credit" autocomplete="off" placeholder="请输入学分" class="layui-input">
	    </div>
	  </div>
	  
	  <div class="layui-form-item">
	    <input type="button" onclick="submitForm()"  value="添加"/>
	  </div>
	</form>
	
	<script type="text/javascript">
		function submitForm() {
			$.post(
				'${path}/course?method=insert',
				$('#formId').serialize(), // 可以把form表的里面的数据自动封装成json格式
				function(jsonResult) {
					console.log(jsonResult);
					mylayer.okMsg(jsonResult.msg);
					
					//当你在iframe页面关闭自身时获得当前弹出框的index索引
	                var index = parent.layer.getFrameIndex(window.name);
                     
                     // js一个方法，定时器，1000毫秒之后自动执行function里面的代码
                     setTimeout(function() {
                         // 关闭弹出层
                         parent.layer.close(index);
                         // 刷新父页面
                         window.parent.location.reload();
                     }, 1000);
					
				},
				'json'
			);
		}
	</script>
</body>
</html>